# INSTRUCTIONS:
# -------------
# is_triggered_only - Triggered from within the code or by event effects. DO NOT REMOVE THE STOCK ONES.
# months - The number of months this CB will be valid. Only works for triggered CBs.
# prerequisites - A condition that automatically activates a CB. Does not work for triggered CBs.
# no_opinion_hit - If yes you get no negative opinion from this
#
# ROOT = attacker
# FROM = target
#
# NOTE: The order in which the peace options are listed is the order in which the AI will normally prioritize them in peace treaties
#
# TRIGGERED - Triggered from within the code or by event effects
# --------------------------------------------------------------

# Restoration of recently broken PU
cb_restore_personal_union = {
	valid_for_subject = no

	is_triggered_only = yes
	months = 240

	prerequisites = {
		OR = {
			government = monarchy
			government = dutch_republic
		}
		is_revolution_target = no
		FROM = {
			government = monarchy
			is_subject = no
		}
	}

	war_goal = take_capital_personal_union
}

# Defected province
cb_defection = {
	valid_for_subject = no

	is_triggered_only = yes
	months = 12

	war_goal = take_core_defection
}

# Cancelled loan
cb_loan_cancelled = {
	valid_for_subject = no

	is_triggered_only = yes
	months = 12

	war_goal = superiority_loan
}

# Hostile spy discovered
cb_spy_discovered = {
	valid_for_subject = no

	is_triggered_only = yes
	months = 12

	war_goal = superiority_spy
}

# Vassal that broke free
cb_disloyal_vassal = {
	valid_for_subject = no

	is_triggered_only = yes
	months = 120

	war_goal = take_capital_disloyal
}

# A HRE prince has been annexed
cb_hre_attacked = {
	valid_for_subject = no

	is_triggered_only = yes
	months = 60

	war_goal = take_province_hre
}

# War of Honor
cb_insult = {
	valid_for_subject = no

	is_triggered_only = yes

	months = 12

	war_goal = superiority_insult_mutual
}

# Dishonored an alliance
cb_dishonored_call = {
	valid_for_subject = no

	is_triggered_only = yes
	months = 36

	war_goal = superiority_insult
}

# CB for vassalization missions
cb_vassalize_mission = {
	valid_for_subject = no

	is_triggered_only = yes
	months = 120

	war_goal = take_capital_vassalize
}

# CB for fabricated claim on throne. (from events)
cb_fabricated_claims = {
	valid_for_subject = no

	is_triggered_only = yes
	months = 12

	war_goal = take_capital_fabricated_claims
}

# CB for Emperor against HRE members that refuse religious conformance
cb_religious_conformance = {
	valid_for_subject = no

	is_triggered_only = yes
	months = 24

	war_goal = take_capital_conformance
}

# Friction along a border
cb_border_war = {
	valid_for_subject = no

	is_triggered_only = yes
	months = 12

	war_goal = take_border
}

# Trade War (from events and others)
cb_trade_war_triggered = {
	valid_for_subject = no

	is_triggered_only = yes
	months = 24

	war_goal = superiority_trade

	attacker_disabled_po = {
		po_demand_provinces
		po_revoke_cores
		po_release_vassals
		po_release_annexed
		po_return_cores
		po_become_vassal
		po_become_tributary_state
		po_form_personal_union
		po_transfer_vassals
	}
}

cb_trade_conflict = {
	valid_for_subject = no

	is_triggered_only = yes
	months = 24

	war_goal = blockade_ports

	attacker_disabled_po = {
		po_demand_provinces
		po_revoke_cores
		po_release_vassals
		po_release_annexed
		po_return_cores
		po_become_vassal
		po_form_personal_union
		po_become_tributary_state
		po_transfer_vassals
	}
}

cb_trade_league_conflict = {
	valid_for_subject = no

	prerequisites = {
		is_trade_league_leader = yes
		can_justify_trade_conflict = FROM
	}
	months = 24

	war_goal = blockade_ports

	attacker_disabled_po = {
		po_demand_provinces
		po_revoke_cores
		po_release_vassals
		po_release_annexed
		po_return_cores
		po_become_vassal
		po_become_tributary_state
		po_form_personal_union
		po_transfer_vassals
	}
}

cb_annex = {
	valid_for_subject = no

	is_triggered_only = yes
	months = 24

	war_goal = annex_country
}

cb_change_government = {
	valid_for_subject = no

	is_triggered_only = yes
	months = 120

	war_goal = war_goal_change_government
}

# AUTOMATIC - Constantly in effect while 'prerequisites' is true
# --------------------------------------------------------------

# One OPM can try to humiliate another OPM.
cb_humiliate = {
	valid_for_subject = no

	prerequisites = {
		has_dlc = "Conquest of Paradise"
		government = native_council
		NOT = {
			truce_with = FROM
			num_of_cities = 2
			FROM = {
				num_of_cities = 2
			}
		}
		is_neighbor_of = FROM
		is_revolution_target = no
	}

	war_goal = humiliate
}


# Temporary claim CB (mostly used by missions)
cb_conquest = {

	prerequisites = {
		claim = FROM
		is_revolution_target = no
	}

	war_goal = take_claim
}

# We can take core provinces at no badboy
cb_core = {

	prerequisites = {
		core_claim = FROM
		is_revolution_target = no
	}

	war_goal = take_core
}

# Independence War
cb_independence_war = {
	exclusive = yes
	independence = yes

	prerequisites = {
		is_subject_other_than_tributary_trigger = yes
		is_subject_of = FROM
		NOT = { is_colonial_nation_of = FROM }
		OR = {
			NOT = { government = daimyo }
			NOT = { from = { government = shogunate } }
		}
		is_revolution_target = no
	}

	war_goal = defend_capital_independence
}

# Colonial Independance
cb_colonial_independance_war = {
	exclusive = yes
	independence = yes

	prerequisites = {
		is_subject = yes
		is_colonial_nation_of = FROM
		is_revolution_target = no
	}

	war_goal = defend_capital_independence
}

# Nationalism
cb_nationalist = {
	
	prerequisites = {
		dip_tech = 68
		is_free_or_tributary_trigger = yes
		culture_group_claim = FROM
		is_revolution_target = no
	}
	
	war_goal = take_province_nationalist
}

# Napoleonic era imperialism
cb_imperial = {
	valid_for_subject = no
	
	prerequisites = {
		OR = {
			dip_tech = 68
			invasion_nation = yes
		}
		NOT = { government = parliamentary_republic }
		NOT = { government = presidental_republic }
		NOT = { government = parliamentary_monarchy }
		is_free_or_tributary_trigger = yes
		is_revolution_target = no
	}
	
	war_goal = take_capital_imperial
}

# Daimyo on Japan
cb_daimyo_annex = {
	valid_for_subject = no
	exclusive = yes
	independence = yes

	prerequisites = {
		is_subject = yes
		OR = {
			vassal_of = FROM
			junior_union_with = FROM
		}
		government = daimyo
		from = { government = shogunate }
		is_revolution_target = no
	}
	
	war_goal = annex_country
}

cb_independent_daimyo_annex = {
	valid_for_subject = no
	exclusive = yes

	prerequisites = {
		is_subject = no
		NOT = {
			vassal_of = FROM
			junior_union_with = FROM
		}
		government = daimyo
		from = { government = shogunate }
		is_revolution_target = no
	}
	
	war_goal = annex_country
}

cb_shogun_annex = {
	valid_for_subject = no

	prerequisites = {
		government = shogunate
		from = {
			government = daimyo
			OR = {
				num_of_cities = 10
				is_subject = no
			}
		}
		is_revolution_target = no
	}
	
	war_goal = annex_country
}

# Sengoku - Daimyo infighting
cb_sengoku = {
	valid_for_subject = no

	prerequisites = {
		government = daimyo
		is_neighbor_of = FROM
		is_subject = yes
		from = {
			government = daimyo
			is_subject = yes
		}
		is_revolution_target = no
	}
	
	war_goal = annex_country
}

# Revolutionary CB
cb_revolutionary = {
	valid_for_subject = no
	
	prerequisites = {
		is_neighbor_of = FROM
		cb_on_government_enemies = yes
		NOT = {
			government = papal_government
			government = steppe_horde
			government = dutch_republic
			government = celestial_empire
			government = iqta
			government = daimyo
			government = shogunate
			government = colonial_government
			government = native_council
			government = caliphate
		}
		FROM = {
			NOT = {
				government = papal_government
				government = steppe_horde
				government = dutch_republic
				government = celestial_empire
				government = iqta
				government = daimyo
				government = shogunate
				government = colonial_government
				government = native_council
				government = caliphate
			}
		}
		OR = {
			AND = {
				government = monarchy
				FROM = { government = republic }
			}
			AND = {
				government = republic
				NOT = { FROM = { government = republic } }
			}
			AND = {
				NOT = { government = communist_dictatorship }
				NOT = { government = socialist_republic }
				OR = {
					FROM = { government = communist_dictatorship }
					FROM = { government = socialist_republic }
				}
			}
			AND = {
				OR = {
					government = communist_dictatorship
					government = socialist_republic
				}
				FROM = { NOT = { government = communist_dictatorship } }
				FROM = { NOT = { government = socialist_republic } }
			}
			AND = {
				government = fascist_dictatorship
				FROM = { government = fascist_dictatorship }
			}
			AND = {
				NOT = { government = fascist_dictatorship }
				FROM = { government = fascist_dictatorship }
			}
		}
		is_revolution_target = no
	}
	
	war_goal = war_goal_change_government_mutual
}

# Colonialist CB
cb_colonial = {
	
	prerequisites = {
		colony_claim = FROM
		is_revolution_target = no
	}
	
	war_goal = take_colony
}

# Liberation CB
cb_liberation = {
	
	prerequisites = {
		always = no		#just for some historical wars.
	}
	
	war_goal = take_capital_liberation
}

# Holy War
cb_crusade = {
	valid_for_subject = no

	prerequisites = {
		is_neighbor_of = FROM
		NOT = { religion_group = FROM }
		NOT = {	has_matching_religion = FROM }
		NOT = { religion = secularism }
		OR = {
			AND = {
				crusade_target = { tag = FROM }
				religion = catholic
			}
			cb_on_religious_enemies = yes
		}
		is_revolution_target = no
	}
	
	war_goal = superiority_crusade
}

# Defender of the Faith
cb_defender_of_the_faith = {
	valid_for_subject = no
	
	prerequisites = {
		is_defender_of_faith = yes
		is_neighbor_of = FROM
		NOT = {	has_matching_religion = FROM }
		cb_on_religious_enemies = yes
		is_revolution_target = no
		OR = {
			hre_religion_treaty = no
			capital_scope = { is_part_of_hre = no }
			FROM = { capital_scope = { is_part_of_hre = no } }
		}		
	}
	
	war_goal = defend_country_faith
}

# Purging of Heresy
cb_heretic = {
	valid_for_subject = no
	
	prerequisites = {
		is_neighbor_of = FROM
		cb_on_religious_enemies = yes
		religion_group = from
		NOT = {	has_matching_religion = FROM }
		OR = {
			NOT = { has_dlc = "Art of War" }
			hre_religion_treaty = no
			capital_scope = { is_part_of_hre = no }
			FROM = { capital_scope = { is_part_of_hre = no } }
		}		
		is_revolution_target = no
	}
	
	allowed_provinces = {
		always = yes
	}

	war_goal = superiority_heretic
}

# Excommunication War
cb_excommunication = {
	valid_for_subject = no
	
	prerequisites = {
		FROM = {
			is_excommunicated = yes
			religion = catholic
		}
		religion = catholic
		is_excommunicated = no
		FROM = {
			is_neighbor_of = ROOT
			any_owned_province = {
				OR = {
					is_core = ROOT
					is_claim = ROOT
					any_neighbor_province = {
						owned_by = ROOT
					}
				}
			}
		}
		OR = {
			hre_religion_treaty = no
			capital_scope = { is_part_of_hre = no }
			FROM = { capital_scope = { is_part_of_hre = no } }
		}
		is_revolution_target = no
	}

	war_goal = take_province_excommunication
}

# Trade War
cb_trade_war = {
	
	prerequisites = {
		
		OR = {
			AND = {
				trade_embargo_by = FROM
				NOT = { FROM = { trade_embargo_by = ROOT } }
			}
			AND = {
				government = merchant_republic
				FROM = { government = merchant_republic }
			}
		}
		is_revolution_target = no
	}
	

	war_goal = superiority_trade_mutual

	attacker_disabled_po = {
		po_demand_provinces
		po_revoke_cores
		po_release_vassals
		po_release_annexed
		po_return_cores
		po_become_vassal
		po_become_tributary_state
		po_form_personal_union
		po_transfer_vassals
	}
}

# Trade War for embargoed Trade League members
cb_trade_league_dispute = {

	prerequisites = {
		is_trade_league_leader = yes
		NOT = { ROOT = { trade_embargo_by = FROM } }
		ROOT = { trade_league_embargoed_by = FROM }
		is_revolution_target = no
	}
	war_goal = superiority_trade_mutual

	attacker_disabled_po = {
		po_demand_provinces
		po_revoke_cores
		po_release_vassals
		po_release_annexed
		po_return_cores
		po_become_vassal
		po_become_tributary_state
		po_form_personal_union
		po_transfer_vassals
	}
}

# Imperial Ban
cb_imperial_ban = {
	valid_for_subject = no

	prerequisites = {
		is_emperor = yes
		is_imperial_ban_allowed = yes
		FROM = {
			capital_scope = { is_part_of_hre = no }
			any_owned_province = {
				is_part_of_hre = yes
			}
		}
		is_revolution_target = no
	}
	
	war_goal = take_province_ban
}

# Liberate Elector
cb_liberate_elector = {
	valid_for_subject = no

	prerequisites = {
		is_emperor = yes
		FROM = {
			any_subject_country = {
				is_elector = yes
			}			
		}
		is_revolution_target = no
	}
	
	war_goal = superiority_liberation
}

# Coalition CB
cb_super_badboy = {
	coalition = yes

	prerequisites = {
		coalition_target = FROM
		NOT = { FROM = { is_in_coalition_war = yes } }
		num_of_coalition_members = 3
		has_opinion_modifier = {
			modifier = aggressive_expansion
			who = FROM
		}
		is_revolution_target = no
	}
	
	war_goal = superiority_punitive
}


# Claim Throne
cb_claim_throne = {
	valid_for_subject = no
	
	prerequisites = {
		succession_claim = FROM
		is_revolution_target = no
	}
	
	war_goal = take_capital_throne
}

# Horde vs Civilized
cb_horde_vs_civ = {
	valid_for_subject = no

	prerequisites = {
		is_neighbor_of = FROM
		FROM = {
			is_nomad = no
		}
		is_nomad = yes
		is_revolution_target = no
	}
	
	war_goal = superiority_horde
}

# Tribal vs Tribal Feud
cb_tribal_feud = {
	valid_for_subject = no

	prerequisites = {
		is_nomad = yes
		FROM = {
			is_nomad = yes
		}
		is_neighbor_of = FROM
		is_revolution_target = no
	}
	
	war_goal = take_province_tribal_feud
}

# Revoke electorate
cb_revoke_electorate = {
	no_opinion_hit = yes

	prerequisites = {
		NOT = { has_dlc = "Common Sense" } # replaced by revoke elector diploaction
		NOT = { has_dlc = "Art of War" } # breaks league system
		FROM = {
			is_elector = yes
		}
		is_emperor = yes
		NOT = { religion = FROM }
		is_revolution_target = no
	}
	
	war_goal = revoke_elector
}

# When someone is privateering in a node that you trade and have some power in.
cb_privateers = {
	
	prerequisites = {
		FROM = {
			has_privateers = yes
		}
		or = {
			home_trade_node = {
				trade_share = {
					country = ROOT
					share = 10
				}
				privateer_power = {
					country = FROM
					share = 1
				}
			}
			any_active_trade_node = {
				trade_share = {
					country = ROOT
					share = 10
				}
				privateer_power = {
					country = FROM
					share = 1
				}
			}
		}
		is_revolution_target = no
	}
	
	war_goal = blockade_ports
}

# War in support of rebels
cb_support_rebels = {
	support_rebels = yes
	valid_for_subject = no
	
	prerequisites = {
		has_dlc = "Art of War"
		has_spawned_supported_rebels = FROM
		is_revolution_target = no
	}
	
	war_goal = take_capital_support_rebels
}

# Revolution
cb_crush_the_revolution = {
	ai_peace_desire = -50
	valid_for_subject = no
	

	prerequisites = {
		OR = {
			capital_scope = { continent = europe }
			is_neighbor_of = FROM
		}
		revolution_target_exists = yes
		is_revolution_target = no
		is_free_or_tributary_trigger = yes
		OR = {
			government = enlightened_despotism
			government = despotic_monarchy
			government = feudal_monarchy
			government = administrative_monarchy
			government = constitutional_monarchy
			government = bureaucratic_despotism
		}
		NOT = {
			revolution_target = {
				war_with = ROOT
			}
			revolution_target = {
				truce_with = ROOT
			}
			revolution_target = {
				alliance_with = ROOT
			}  
		}
		FROM = {
			is_revolution_target = yes
		}
	}
	
	war_goal = take_capital_revolution
}

cb_spread_the_revolution = {
	valid_for_subject = no

	prerequisites = {
		is_revolution_target = yes
		OR = {
			ai = no
			capital_scope = { continent = europe }
		}
		FROM = {
			NOT = { is_subject_of = ROOT }
			NOT = { government = revolutionary_republic }
		}
	}
	
	war_goal = superiority_revolution
}

cb_religious_league = {
	league = yes
	ai_peace_desire = -50
	
	valid_for_subject = no

	prerequisites = {
		has_dlc = "Art of War"
		is_in_league_war = no
		FROM = {
			is_emperor = yes
			is_in_league_war = no
		}
		is_league_leader = yes
		hre_heretic_religion = ROOT
		is_league_enemy = FROM
		is_revolution_target = no
	}
	
	war_goal = superiority_religious_league
}

cb_flower_wars = {
	
	valid_for_subject = no

	prerequisites = {
		has_dlc = "El Dorado"
		religion = nahuatl
		is_free_or_tributary_trigger = yes
		is_religion_reformed = no
		FROM = {
			NOT = { is_subject_of = ROOT }
		}
		is_neighbor_of = FROM
	}
	
	war_goal = take_capital_vassalize
}

cb_maya_expansion = {
	
	valid_for_subject = no

	prerequisites = {
		has_dlc = "El Dorado"
		religion = mesoamerican_religion
		is_free_or_tributary_trigger = yes
		is_religion_reformed = no
		FROM = {
			NOT = { is_subject_of = ROOT }
			religion_group = pagan
		}
		is_neighbor_of = FROM
	}
	
	war_goal = take_capital_mayan
}

# Rival Humiliate CB
cb_humiliate_rotw = {
	valid_for_subject = no

	prerequisites = {
		NOT = {
			truce_with = FROM
		}
		ai = no
		is_rival = FROM
		is_revolution_target = no
	}

	attacker_disabled_po = {
		po_demand_provinces
		po_release_vassals
		po_release_annexed
		po_return_cores
		po_become_vassal
		po_become_tributary_state
		po_form_personal_union
		po_transfer_vassals
	}

	war_goal = humiliate_rotw
}
# Reunification of China
cb_chinese_unification = {
	valid_for_subject = no
	
	prerequisites = {
		is_free_or_tributary_trigger = yes
		OR = {
			AND = {
				has_dlc = "Mandate of Heaven"
				is_emperor_of_china = yes
			}
			AND = {
				NOT = { has_dlc = "Mandate of Heaven" }
				culture_group = east_asian #Chinese

				OR = {	#Manchus won't get this unless they unify
					tag = MCH
					tag = QNG
					NOT = { primary_culture = manchu }
				}
			}
		}
		FROM = { #Applies against other powers in China unless they have the Mandate of Heaven
			NOT = { is_subject_of = ROOT }
			OR = {
				has_dlc = "Mandate of Heaven"
				culture_group = east_asian #Chinese
			}
			any_owned_province = {
				OR = {
					region = north_china_region
					region = xinan_region
					region = south_china_region
				}
			}
			NOT = { has_country_modifier = the_mandate_of_heaven }
		}
		is_neighbor_of = FROM
	}
	
	war_goal = superiority_chinese_unification
}

# Take the Mandate of Heaven
cb_take_mandate = {
	valid_for_subject = no

	prerequisites = {
		has_dlc = "Mandate of Heaven"
		is_subject = no
		is_neighbor_of = FROM
		FROM = { is_emperor_of_china = yes }
		OR = {
			religion_group = pagan
			religion_group = eastern
		}
	}

	war_goal = take_capital_take_mandate
}
# Force migration
cb_force_migration = {

	valid_for_subject = no

	prerequisites = {
		has_dlc = "The Cossacks"
		is_neighbor_of = FROM
		is_free_or_tributary_trigger = yes
		FROM = {
			can_migrate = yes
			is_free_or_tributary_trigger = yes
		}
	}
	war_goal = force_migration
}

# Forced our ally to break alliance
cb_forced_break_alliance = {

	valid_for_subject = no
	is_triggered_only = yes
	months = 120
	
	war_goal = superiority_insult
}

cb_force_tributary = {

	valid_for_subject = no

	prerequisites = {
		has_dlc = "Mandate of Heaven"
		is_emperor_of_china = yes
		FROM = { is_subject = no }
		is_neighbor_of = FROM
	}
	
	war_goal = take_capital_force_tributary
}

# Spread Communism
cb_spread_communism = {
	valid_for_subject = no
	
	prerequisites = {
		is_subject = no
		OR = {
			government = socialist_republic
			government = communist_dictatorship
		}
		FROM = {
			NOT = { government = socialist_republic }
			NOT = { government = communist_dictatorship }
		}
		is_revolution_target = no
	}

	war_goal = war_goal_change_government	
}

# Spread Fascism
cb_spread_fascism = {
	valid_for_subject = no
	
	prerequisites = {
		is_subject = no
		government = fascist_dictatorship
		FROM = {
			NOT = { government = fascist_dictatorship }
		}
		is_revolution_target = no
	}

	war_goal = war_goal_change_government	
}

# Export Democracy
cb_spread_democracy = {
	valid_for_subject = no
	
	prerequisites = {
		is_subject = no
		OR = {
			government = parliamentary_republic
			government = presidental_republic
			government = parliamentary_monarchy
			government = constitutional_monarchy
			government = constitutional_republic
		}
		FROM = {
			NOT = {
				OR = {
					government = parliamentary_republic
					government = presidental_republic
					government = parliamentary_monarchy
					government = constitutional_monarchy
					government = constitutional_republic
					government = english_monarchy
					government = papal_government
					government = steppe_horde
					government = dutch_republic
					government = celestial_empire
					government = iqta
					government = daimyo
					government = shogunate
					government = colonial_government
					government = native_council
					government = caliphate
					government = revolutionary_republic
					government = plutocratic_republic
				}
			}
		}
		is_revolution_target = no
	}

	war_goal = war_goal_change_government	
}

# Imperial Rome cb
cb_roman_imperial = {
	valid_for_subject = no
	
	prerequisites = {
		has_country_flag = rome_formed
		tag = ROM
		is_subject = no
		FROM = { #Imperial borders
			NOT = { is_subject_of = ROOT }
			any_owned_province = {
				OR = {
					region = france_region
					region = iberia_region
					region = italy_region
					region = balkan_region
					region = low_countries_region
					region = british_isles_region
					region = anatolia_region
					region = mashriq_region
					region = egypt_region
					region = maghreb_region
					region = north_german_region
					region = south_german_region
				}
			}
		}
		is_neighbor_of = FROM
		
		is_revolution_target = no
	}
	
	war_goal = superiority_roman_imperialism
}

# Caliphal Subjugation
cb_caliphal_subjugation = {
	valid_for_subject = no
	
	prerequisites = {
		government = caliphate
		is_subject = no
		FROM = {
			religion_group = muslim
			NOT = { is_subject_of = ROOT }
		}
		is_neighbor_of = FROM
		
		is_revolution_target = no
	}
	
	war_goal = superiority_caliphal_subjugation
}

# Sphere country
#cb_sphere_of_influence = {
#	valid_for_subject = no
#	
#	prerequisites = {
#		is_great_power = yes
#		adm_tech = 77
#		FROM = {
#			NOT = { is_subject_of = ROOT }
#			is_great_power = no
#		}
#		
#		is_revolution_target = no
#	}
#	
#	war_goal = superiority_sphere
#	
#	attacker_disabled_po = {
#		po_annex
#		po_demand_provinces
#		po_revoke_cores
#		po_release_vassals
#		po_release_annexed
#		po_return_cores
#	}
#}

cb_salic_reunification = {
	valid_for_subject = no

	is_triggered_only = yes
	months = 600

	prerequisites = {
		government = salic_monarchy
		is_subject = no
		FROM = {
			government = salic_monarchy
			is_subject = no
		}
	}

	war_goal = take_capital_salic
}